package com.huaweicloud.saaslanding.install.properties;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import com.huaweicloud.saaslanding.install.constant.ModelConstant;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Component
@RefreshScope
@ConfigurationProperties(prefix = ModelConstant.SMS_INFO_PREFIX)
public class Sms {
    // 代理地址，如果不需要可以为空
    private String proxy;

    // 代理地址端口号
    private Integer proxyPort;

    // APP接入地址(在控制台"应用管理"页面获取)+接口访问URI
    private String url;
    private String appKey;
    private String appSecret;

    // 国内短信签名通道号或国际/港澳台短信通道号
    private String sender;

    // Minimum interval seconds between two request
    private Integer minInterval = 60;
    private Integer maxRequestPerDay = 20;
    private Map<NotificationEvent, SmsConfig> notificationEvents = new ConcurrentHashMap<>();
    
    @Getter
    @Setter
    public static class SmsConfig {
        /**
         *  短信模板id
         */
        private String templateId;

        /**
         *  仅在templateId指定的模板类型为通用模板时生效且必填，用于指定在通用模板短信内容前面补充的签名。
         */
        private String signature;
    }

    public enum NotificationEvent {
        LOGIN,
        RESET_PASSWORD,
        UPDATE_PERSON_INFO,
        ;
    }

}
